package com.zr.repertory.areLocation.mapper;

import com.zr.areLocation.model.AreLocationSelectVo;
import com.zr.areLocation.model.AreLocationVo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * Created by 77509 on 2019/11/20.
 */
@Mapper
public interface AreLocationMapper {

    @Select("select count(id) from areLocation where warehouseMarkCode = #{warehouseMarkCode}")
    int queryByCode(@NotBlank(message = "库房标识编码不能为空！") String warehouseMarkCode);

    @Select("select count(id) from areLocation where warehouseMarkName = #{warehouseMarkName}")
    int queryByName(String name);

    @Insert("insert into areLocation(warehouseMarkCode,warehouseMarkName,warehouseMarkRemark,status)" +
            " values(#{warehouseMarkCode},#{warehouseMarkName},#{warehouseMarkRemark},#{status})")
    void add(AreLocationVo areLocationVo);

    @Select("select * from areLocation where id = #{id}")
    AreLocationVo queryById(@NotNull(message = "修改时id不能为空") Integer id);

    @Select("select * from areLocation where warehouseMarkName = #{warehouseMarkName}")
    AreLocationVo queryAreLocationVoByName(@NotBlank(message = "库房标识名称不能为空！") String warehouseMarkName);

    @Update("update areLocation set warehouseMarkName=#{warehouseMarkName},warehouseMarkRemark=#{warehouseMarkRemark}," +
            "updateName=#{updateName},updateTime=#{updateTime}" +
            " where id=#{id} ")
    int update(AreLocationVo areLocationVo1);

    int queryCount(AreLocationSelectVo areLocationSelectVo);

    List<AreLocationVo> queryDate(AreLocationSelectVo areLocationSelectVo);

    @Update("update areLocation set status=#{status},updateName=#{updateName}," +
            "updateTime=#{updateTime} where id = #{id}")
    void updateStatus(AreLocationVo areLocationVo);
}
